//
//  EMBaseHideNavBarViewController.m
//  EasyMoney
//
//  Created by 邓乐 on 2020/1/7.
//  Copyright © 2020 zh. All rights reserved.
//

#import "EMBaseHideNavBarViewController.h"

@interface EMBaseHideNavBarViewController ()
@property(nonatomic, assign) int hideStatus;
@end

@implementation EMBaseHideNavBarViewController

-(instancetype)init
{
    self = [super init];
    if (self) {
        _hideStatus = 0;
    }
    return self;
}

-(instancetype)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self) {
        _hideStatus = 0;
    }
    return self;
}

-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        _hideStatus = 0;
    }
    return self;
}

-(BOOL)needHideNavgationBar
{
    return YES;
}


-(void)changeHideStatus:(BOOL)status
{
    if (status == YES) {
        _hideStatus++;
    }
}


-(void)viewWillAppear:(BOOL)animated
{
    if (_hideStatus > 0) {
        [self.navigationController setNavigationBarHidden:YES animated:YES];
        _hideStatus--;
    }
    [super viewWillAppear:animated];
}

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    if (_hideStatus > 0) {
        [self.navigationController setNavigationBarHidden:NO animated:YES];
        _hideStatus--;
    }
}

@end
